﻿Public Class frmTemplate
    Dim dbBase As New dbUser
    Dim frmCtrl As New FormControl
    Dim dsBase As DataSet
    Dim Var As New varDeclare

    Private Sub tsNew_Click(ByVal sender As ToolbarHeader) Handles ToolbarHeader1.tsNewClick
        Textbox(True, True)
    End Sub

    Private Sub tsEdit_Click(ByVal sender As ToolbarHeader) Handles ToolbarHeader1.tsEditClick
        Textbox(True, False)
    End Sub

    Private Sub tsDelete_Click(ByVal sender As ToolbarHeader) Handles ToolbarHeader1.tsDeleteClick
        frmCtrl.openChild(New frmTemplate, Me.ParentForm)
    End Sub

    Private Sub tsPrint_Click(ByVal sender As ToolbarHeader) Handles ToolbarHeader1.tsPrintClick
        ''Event 
    End Sub

    Private Sub tsSave_Click(ByVal sender As ToolbarHeader) Handles ToolbarHeader1.tsSaveClick
        frmCtrl.openChild(New frmTemplate, Me.ParentForm)
    End Sub

    Private Sub tsRefresh_Click(ByVal sender As ToolbarHeader) Handles ToolbarHeader1.tsRefreshClick
        frmCtrl.openChild(New frmTemplate, Me.ParentForm)
    End Sub

    Private Sub tsCancel_Click(ByVal sender As ToolbarHeader) Handles ToolbarHeader1.tsCancelClick
        frmCtrl.openChild(New frmTemplate, Me.ParentForm)
    End Sub

    Private Sub GridCellEnter_Click(ByVal sender As GridAndFind, KeyValue As String) Handles GridAndFind1.GridCellEnter
        Dim dvFind As DataView = New DataView(dsBase.Tables(0))
        dvFind.RowFilter = "[userID] = '" & KeyValue & "'"
        textbox1.Text = dvFind.Item(0).Row("username").ToString()
    End Sub

    Private Sub frmGLAccount_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.WindowState = FormWindowState.Maximized
        dsBase = dbBase.UserList(Var.CompID)
        Textbox(False, False)
        GridAndFind1.Initialize(dsBase, "userID", ToolbarHeader1, Me, True)
        ToolbarHeader1.Iniliaze("Form : Testing", Me, Nothing, GridAndFind1.getDataGridView(), "userID")
    End Sub

    Private Sub Textbox(st As Boolean, clear As Boolean)
        ComboBox1.Enabled = st
        If (st) Then
            st = False
        Else : st = True
        End If
        textbox1.ReadOnly = st
        textbox1.BackColor = Color.White
        textbox2.ReadOnly = st
        textbox2.BackColor = Color.White
        GridAndFind1.Enabled = st
        If (clear) Then
            textbox1.Text = ""
            textbox2.Text = ""
        End If
    End Sub
End Class